<html>
<head><meta charset="utf-8"><title>Variance &amp; Generalizer work · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html">Variance &amp; Generalizer work</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206377895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206377895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206377895">(Aug 09 2020 at 04:15)</a>:</h4>
<p><span class="user-mention" data-user-id="218710">@David Ross</span>  and I have been working on on the <a href="https://github.com/rust-lang/chalk/issues/365">.chalk syntax writer</a> for the last couple months. While there are still remaining work items for the syntax writer, we are interested in branching out into some of the core solver functionality.  Does anyone have a suggestion for a good "second" issue that is a little more advanced, focused on the solver code, and has a clear direction to head in?</p>



<a name="206409351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409351">(Aug 09 2020 at 19:55)</a>:</h4>
<p>Hmm</p>



<a name="206409392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409392">(Aug 09 2020 at 19:56)</a>:</h4>
<p>The "has a clear direction" point is probably the hardest to satisfy</p>



<a name="206409401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409401">(Aug 09 2020 at 19:57)</a>:</h4>
<p>It would be nice to get the Variance work pushed over the edge: <a href="https://github.com/rust-lang/chalk/pull/520">https://github.com/rust-lang/chalk/pull/520</a></p>



<a name="206409409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409409">(Aug 09 2020 at 19:57)</a>:</h4>
<p>I don't have a ton of time at the moment</p>



<a name="206409452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409452">(Aug 09 2020 at 19:58)</a>:</h4>
<p>I think the big thing that needs to be done for that is porting the Generalizer from rustc</p>



<a name="206409463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409463">(Aug 09 2020 at 19:58)</a>:</h4>
<p>And tests</p>



<a name="206409472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409472">(Aug 09 2020 at 19:59)</a>:</h4>
<p>There's also the canonicalization of placeholders</p>



<a name="206409476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409476">(Aug 09 2020 at 19:59)</a>:</h4>
<p>Both <span class="user-mention" data-user-id="251766">@Areredify</span> and I have a branch for that though that only needs a bit of work</p>



<a name="206409526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409526">(Aug 09 2020 at 20:00)</a>:</h4>
<p>Maybe specialization support?</p>



<a name="206409540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409540">(Aug 09 2020 at 20:01)</a>:</h4>
<p>But I really don't know how much support is there already/what the status is and what needs to be done</p>



<a name="206409541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409541">(Aug 09 2020 at 20:01)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> would know more</p>



<a name="206409546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409546">(Aug 09 2020 at 20:01)</a>:</h4>
<p>(issue <a href="https://github.com/rust-lang-nursery/chalk/issues/9">chalk#9</a>)</p>



<a name="206409588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409588">(Aug 09 2020 at 20:02)</a>:</h4>
<p>If you two are interested, there's a some work on the rustc side to do</p>



<a name="206409593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409593">(Aug 09 2020 at 20:02)</a>:</h4>
<p>some towards to "type library"</p>



<a name="206409660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409660">(Aug 09 2020 at 20:05)</a>:</h4>
<p>but also, region/lifetime stuff (specifically around late-bound regions and hrtb),</p>



<a name="206409699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409699">(Aug 09 2020 at 20:06)</a>:</h4>
<p>also, around <code>Param</code>s and what to do with those</p>



<a name="206409766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/206409766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#206409766">(Aug 09 2020 at 20:08)</a>:</h4>
<p>There's also changing <code>RustIrDatabase</code> to be "modular" (<a href="https://github.com/rust-lang-nursery/chalk/issues/506">chalk#506</a>), which essentially means removing a lot of the structs in <code>rust_ir</code> and make <code>RustIrDatabase</code> returns bits and pieces as needed. Similar to the queries in <code>TyCtxt</code></p>



<a name="207047109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207047109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207047109">(Aug 16 2020 at 00:45)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> Thanks for listing the options, we looked at a couple of them, and we are interested in taking on the Variance work.</p>



<a name="207154447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207154447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207154447">(Aug 17 2020 at 15:02)</a>:</h4>
<p><span class="user-mention" data-user-id="271698">@Super Tuple</span> oh nice!</p>



<a name="207154504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207154504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207154504">(Aug 17 2020 at 15:03)</a>:</h4>
<p>Um, let me make a note to myself to write up some mentoring notes for this sometime this week</p>



<a name="207749210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207749210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207749210">(Aug 23 2020 at 00:55)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> We've rebased onto master, and are trying to figure out more about Generalizer really is and what's missing about it in chalk. However, we're having a really hard time coming up with failing test cases - any tips?</p>
<p>I think we've identified unify_var_ty (at <a href="https://github.com/rust-lang/chalk/blob/99b2db851029ea7b4d25b337d8f5d71d324a8f31/chalk-solve/src/infer/unify.rs#L282">https://github.com/rust-lang/chalk/blob/99b2db851029ea7b4d25b337d8f5d71d324a8f31/chalk-solve/src/infer/unify.rs#L282</a>) as the thing which needs to change for this.</p>
<p>However, we're stuck at the step of figuring out exactly why the current code is wrong. We've both attempted to create failing tests, since that would be an easy proof of wrongness/our correcting it, but... that's been less than successful.</p>
<p>I've tried to port <a href="https://github.com/rust-lang/rust/blob/master/src/test/ui/type-infer-generalize-ty-var.rs">https://github.com/rust-lang/rust/blob/master/src/test/ui/type-infer-generalize-ty-var.rs</a> over in order to get a failing chalk test, but actually turning those expressions it into chalk syntax is difficult. And <span class="user-mention" data-user-id="271698">@Super Tuple</span> has been trying to create fresh test cases which fail</p>



<a name="207751357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207751357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207751357">(Aug 23 2020 at 02:08)</a>:</h4>
<p>Let me look at this tomorrow. I had planned to write some notes on this earlier this week, but didn't get to it. Sorry :(</p>



<a name="207751363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207751363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207751363">(Aug 23 2020 at 02:09)</a>:</h4>
<p>Just quickly (if either of you see this, but I am on mobile): the Generalizer is in rustc (don't remember exactly where atm)</p>



<a name="207751408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207751408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207751408">(Aug 23 2020 at 02:10)</a>:</h4>
<p>I'll go into a bit more detail tomorrow, but IIRC, we need it because of unifying something but I don't remember what exactly atm</p>



<a name="207751419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207751419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207751419">(Aug 23 2020 at 02:11)</a>:</h4>
<p>I too, was a bit lacking on test cases. In general, one area here that needs work is defining a system to actually defining variance of types in tests, then testing that those variances are upheld</p>



<a name="207751462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/207751462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#207751462">(Aug 23 2020 at 02:12)</a>:</h4>
<p>I don't know how around <span class="user-mention" data-user-id="116009">@nikomatsakis</span> will be next week, but maybe he can come up with a few test cases. I'll look at that linked test tomorrow too</p>



<a name="208449469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208449469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208449469">(Aug 29 2020 at 19:18)</a>:</h4>
<p>Alright, I didn't get to this again this week</p>



<a name="208449470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208449470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208449470">(Aug 29 2020 at 19:18)</a>:</h4>
<p>but I'll write some now</p>



<a name="208449504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208449504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208449504">(Aug 29 2020 at 19:19)</a>:</h4>
<p>The<code>Generalizer</code> that needs to be ported is here: <a href="https://github.com/rust-lang/rust/blob/668ef72f4429059240ee361a2f0f748558a5326f/src/librustc_infer/infer/combine.rs#L415">https://github.com/rust-lang/rust/blob/668ef72f4429059240ee361a2f0f748558a5326f/src/librustc_infer/infer/combine.rs#L415</a></p>



<a name="208449962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208449962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208449962">(Aug 29 2020 at 19:30)</a>:</h4>
<p>And it would be used here: <a href="https://github.com/rust-lang/chalk/blob/af079c010a5569c99ac5f7afd3f4b6ecb0ca9d27/chalk-solve/src/infer/unify.rs#L129">https://github.com/rust-lang/chalk/blob/af079c010a5569c99ac5f7afd3f4b6ecb0ca9d27/chalk-solve/src/infer/unify.rs#L129</a></p>



<a name="208450030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208450030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208450030">(Aug 29 2020 at 19:32)</a>:</h4>
<p>This blog post from Niko is helpful: <a href="http://smallcultfollowing.com/babysteps/blog/2014/07/09/an-experimental-new-type-inference-scheme-for-rust/">http://smallcultfollowing.com/babysteps/blog/2014/07/09/an-experimental-new-type-inference-scheme-for-rust/</a></p>



<a name="208450049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208450049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208450049">(Aug 29 2020 at 19:33)</a>:</h4>
<p>The <code>type-infer-generalize-ty-var</code> test is good to port</p>



<a name="208450108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208450108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208450108">(Aug 29 2020 at 19:34)</a>:</h4>
<p>It would be interesting to try to port the <code>println!()</code> case</p>



<a name="208450195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208450195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208450195">(Aug 29 2020 at 19:36)</a>:</h4>
<p>Specifically this case: <a href="https://github.com/rust-lang/rust/blob/master/src/test/ui/chalkify/println.rs">https://github.com/rust-lang/rust/blob/master/src/test/ui/chalkify/println.rs</a></p>



<a name="208450200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208450200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208450200">(Aug 29 2020 at 19:36)</a>:</h4>
<p>Though, that passes using the <em>current</em> PR</p>



<a name="208450219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208450219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208450219">(Aug 29 2020 at 19:37)</a>:</h4>
<p>so, I'm not sure what exactly would fail without the <code>Generalizer</code></p>



<a name="208450945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208450945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208450945">(Aug 29 2020 at 19:54)</a>:</h4>
<p>Here's another test: <a href="https://github.com/rust-lang/rust/blob/master/src/test/ui/regions/regions-scope-chain-example.rs">https://github.com/rust-lang/rust/blob/master/src/test/ui/regions/regions-scope-chain-example.rs</a></p>



<a name="208451272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208451272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208451272">(Aug 29 2020 at 20:00)</a>:</h4>
<p>Hmm, I wonder how worth it would be to just see how many tests in <a href="https://github.com/rust-lang/rust/tree/master/src/test/ui/regions">https://github.com/rust-lang/rust/tree/master/src/test/ui/regions</a> pass (in the rustc integration) with/without the subtyping changes and with/without the <code>Generlizer</code></p>



<a name="208451293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208451293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208451293">(Aug 29 2020 at 20:01)</a>:</h4>
<p>But yeah, any tests in that dir with "subtyping" probably should have some related test in Chalk</p>



<a name="208470583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208470583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208470583">(Aug 30 2020 at 06:02)</a>:</h4>
<p>Thanks for that info. We weren't able to go through it in detail yet, but it looks very useful!</p>
<p>While we didn't spend much time working on chalk today, we did spend some time trying to figure out how to port the regions scope chain example, but we didn't get very far. Ultimately, I think we need to learn quite a bit more about lowering to port these tests, which we will work on.</p>
<p>Next week we are planning to try and implement the generalizer logic w/o test cases. We will use the rustc code you linked, rather than working out what is needed based on test cases.</p>



<a name="208471003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/208471003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#208471003">(Aug 30 2020 at 06:18)</a>:</h4>
<p>No problem! Let me know if there's any other questions.</p>



<a name="209918390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/209918390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#209918390">(Sep 13 2020 at 07:27)</a>:</h4>
<p>Since we've been having quite a hard time figuring out the rustc generalizer tests, and haven't gotten tests from <span class="user-mention" data-user-id="116009">@nikomatsakis</span>, we've just worked today on writing a rough draft.</p>
<p>We're currently stuck on an issue with the way we deal with universes, but should be able to put more time into that next week! It's going a lot faster now that we're working on actually writing code, rather than trying N different ways to understand and port the rustc generalizer tests to chalk.</p>



<a name="210059158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210059158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210059158">(Sep 14 2020 at 20:32)</a>:</h4>
<p>I was hoping to make some tests today</p>



<a name="210059267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210059267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210059267">(Sep 14 2020 at 20:33)</a>:</h4>
<p><span class="user-mention" data-user-id="218710">@David Ross</span>should I be looking at <a href="https://github.com/rust-lang/chalk/pull/609">https://github.com/rust-lang/chalk/pull/609</a> ?</p>



<a name="210061052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210061052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210061052">(Sep 14 2020 at 20:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> that's the right PR</p>



<a name="210067909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210067909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210067909">(Sep 14 2020 at 21:53)</a>:</h4>
<p>So how do we specify the variance for structs btw?</p>



<a name="210067912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210067912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210067912">(Sep 14 2020 at 21:53)</a>:</h4>
<p>or did we not implement that yet in chalk :)</p>



<a name="210069092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210069092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210069092">(Sep 14 2020 at 22:09)</a>:</h4>
<p>ok I have to kick off but I'll push a few tests</p>



<a name="210069102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210069102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210069102">(Sep 14 2020 at 22:09)</a>:</h4>
<p>so far I think it is <em>mostly</em> performing as expecte</p>



<a name="210069109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210069109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210069109">(Sep 14 2020 at 22:09)</a>:</h4>
<p>I need to sit down and make more rigorous tests</p>



<a name="210074111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210074111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210074111">(Sep 14 2020 at 23:16)</a>:</h4>
<p>Re variance for structs: there's a method <code>adt_variance</code> on the new <code>UnificationDatabase</code> trait which we call for determining this. It's hard coded to "Invariant" on everything in chalk, though I imagine we could also calculate it based on struct fields?</p>



<a name="210083065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210083065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210083065">(Sep 15 2020 at 01:46)</a>:</h4>
<p>Well, for tests, we need to be able to define the variance of specific adts. That's just not implemented yet</p>



<a name="210126807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210126807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210126807">(Sep 15 2020 at 13:12)</a>:</h4>
<p>probably we want to be able to write it out in the syntax, e.g., <code>struct Foo&lt;+T&gt;</code> (for covariant)</p>



<a name="210126825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/210126825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#210126825">(Sep 15 2020 at 13:12)</a>:</h4>
<p>the usual notation is <code>+</code> (co), <code>-</code> (contra) and <code>=</code>(in)</p>



<a name="211404298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/211404298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#211404298">(Sep 27 2020 at 08:00)</a>:</h4>
<p>Thanks for adding the test to the PR! We didn't get past fixing the universes issue, but once that has been resolved, we can work towards adding variance annotations.</p>



<a name="211679253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/211679253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#211679253">(Sep 29 2020 at 20:24)</a>:</h4>
<p><span class="user-mention" data-user-id="271698">@Super Tuple</span> <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> do you need help tracking down this universes issue, what is it exactly?</p>



<a name="212189064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212189064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212189064">(Oct 03 2020 at 20:45)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> It's mostly some failing tests we were/are failing to figure out - specifically <code>dyn_lifetime_bound</code>. We're handling generalizing <code>dyn Trait</code> badly, in a way that ruins its structure.</p>
<p>I think we're on a track to solve it, but if we don't get it done by the end of today I'll send an update with everything we've got so far.</p>



<a name="212207402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212207402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212207402">(Oct 04 2020 at 05:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Yes, some help understanding what is going on would definitely give us a boost. Do you think it would be possible to have a synchronous discussion about the generalizer? Would the hour after the Tuesday meeting work for you?</p>



<a name="212241114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212241114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212241114">(Oct 04 2020 at 20:48)</a>:</h4>
<p>I wonder if there is a subset of <a href="https://github.com/rust-lang-nursery/chalk/issues/609">chalk#609</a> that we can get merged into master. I know at least with my original PR, it fixes quite a bit of the rustc test suite</p>



<a name="212294223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212294223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212294223">(Oct 05 2020 at 12:51)</a>:</h4>
<p>I think we could? Specifically, removing the generalizer commit and rebasing it should be pretty simple. Adding in the generalizer correctly without breaking existing tests has been the hardest part of this, and the code before that commit works (and passes nikmatsakis's added tests).</p>



<a name="212302665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212302665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212302665">(Oct 05 2020 at 14:00)</a>:</h4>
<p>Can we do that? I didn't know that the code before the generalizer was added passes the tests</p>



<a name="212476459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212476459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212476459">(Oct 06 2020 at 19:53)</a>:</h4>
<p><span class="user-mention" data-user-id="271698">@Super Tuple</span> the hour after the meeting doesn't work this week but</p>



<a name="212476465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212476465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212476465">(Oct 06 2020 at 19:53)</a>:</h4>
<p>I could schedule some time for friday perhaps, or next monday</p>



<a name="212476477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212476477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212476477">(Oct 06 2020 at 19:53)</a>:</h4>
<p>I think scheduling time is a good idea</p>



<a name="212476493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212476493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212476493">(Oct 06 2020 at 19:53)</a>:</h4>
<p>I am working to make Mondays (I think) my "traits time"</p>



<a name="212476510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212476510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212476510">(Oct 06 2020 at 19:53)</a>:</h4>
<p>stuff keeps coming up but I'm hopeful it will work "Any Day Now"</p>



<a name="212479411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212479411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212479411">(Oct 06 2020 at 20:14)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Both Monday and Friday should work. Friday would have the advantage of proceeding <span class="user-mention" data-user-id="218710">@David Ross</span> and I's work time on Saturday.</p>



<a name="212480252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212480252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212480252">(Oct 06 2020 at 20:19)</a>:</h4>
<p>let's schedule some time on friday then</p>



<a name="212480362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212480362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212480362">(Oct 06 2020 at 20:20)</a>:</h4>
<p>afternoon Eastern time ok?</p>



<a name="212480647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212480647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212480647">(Oct 06 2020 at 20:23)</a>:</h4>
<p>I can do sometime after 3pm EST on Friday. <span class="user-mention" data-user-id="218710">@David Ross</span> What works for you?</p>



<a name="212483364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212483364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212483364">(Oct 06 2020 at 20:45)</a>:</h4>
<p>I'm going to block out 3pm-5pm as another "chalk time"</p>



<a name="212483399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212483399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212483399">(Oct 06 2020 at 20:45)</a>:</h4>
<p>so y'all can ping me then</p>



<a name="212483405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212483405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212483405">(Oct 06 2020 at 20:45)</a>:</h4>
<p>hopefully that works</p>



<a name="212864164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212864164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212864164">(Oct 09 2020 at 19:04)</a>:</h4>
<p>Don't know if still planning on meeting today <span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="271698">@Super Tuple</span> <span class="user-mention" data-user-id="218710">@David Ross</span>, but I'm around too</p>



<a name="212864274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212864274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212864274">(Oct 09 2020 at 19:05)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> I'm here! I haven't received positive confirmation from <span class="user-mention" data-user-id="218710">@David Ross</span> If he is going to make it.</p>



<a name="212864347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212864347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212864347">(Oct 09 2020 at 19:06)</a>:</h4>
<p>Niko doesn't seem to be on</p>



<a name="212864363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212864363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212864363">(Oct 09 2020 at 19:06)</a>:</h4>
<p>But don't know if you saw, but I added a commit to your PR</p>



<a name="212864386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212864386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212864386">(Oct 09 2020 at 19:06)</a>:</h4>
<p>For specifying the variance of adts and fn_defs in tests</p>



<a name="212864744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212864744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212864744">(Oct 09 2020 at 19:10)</a>:</h4>
<p>I haven't seen that - I'll take a look at it now.</p>



<a name="212865445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212865445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212865445">(Oct 09 2020 at 19:19)</a>:</h4>
<p>Let me know if you have any questions in general here</p>



<a name="212865456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212865456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212865456">(Oct 09 2020 at 19:19)</a>:</h4>
<p>Even if <span class="user-mention" data-user-id="116009">@nikomatsakis</span> isn't around, I <em>might</em> be able to answer some</p>



<a name="212950562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212950562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Super Tuple <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212950562">(Oct 11 2020 at 05:52)</a>:</h4>
<p>We made progress fixing the issues uncovered by the existing tests today, only four of the tests are failing now.</p>
<p>Three of them are producing the correct result, albeit the generated lifetime constraints don't match. Is the difference in lifetime constraints an issue? If so, how should we approach fixing them?</p>
<div class="codehilite"><pre><span></span><code>test::existential_types::dyn_associated_type_binding
test::existential_types::dyn_binders_reverse
test::unify::forall_equality
</code></pre></div>


<p>We've also temporarily added two simplified versions of the failing tests to the PR for debugging purposes</p>
<div class="codehilite"><pre><span></span><code>test::unify::forall_equality_solveable_simple
test::unify::forall_equality_unsolveable_simple
</code></pre></div>


<p>The other failing test is a lowering involving specialization (<code>test::coherence::overlapping_assoc_types</code>). Chalk attempts to solve two goals to prove the impl is a specialization, one of which is supposed to succeed. However, neither of them are succeeding, causing the test to fail. We extracted the goal into a test, however, the test produced the expected result! We believe this may be because the solver isn't fresh when doing the tests like it is during specialization checks, but haven't confirmed yet.</p>



<a name="212950716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212950716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212950716">(Oct 11 2020 at 05:58)</a>:</h4>
<p>For reference, full test output: <a href="https://gist.github.com/daboross/d93c33841a3707dbe08e2ee919d39435">https://gist.github.com/daboross/d93c33841a3707dbe08e2ee919d39435</a>, and output from each test with CHALK_DEBUG set: <a href="https://gist.github.com/daboross/0d0cd361b0fac60fa40e108a05595c5d">https://gist.github.com/daboross/0d0cd361b0fac60fa40e108a05595c5d</a></p>



<a name="212950754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212950754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212950754">(Oct 11 2020 at 06:00)</a>:</h4>
<p>As a last note - the fix for the issue we were stuck on last week, about universes, ended up being deceptively simple. We were generalizing the <code>Self</code> parameter implicit in <code>dyn Trait</code> types, and not generalizing it fixed that.</p>



<a name="212962559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212962559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212962559">(Oct 11 2020 at 11:55)</a>:</h4>
<p>Some of the new lifetime constraints look wrong. I've left a comment on the PR explaining a change to<code>relate_binders</code> that should fix this.</p>



<a name="212981637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/212981637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#212981637">(Oct 11 2020 at 21:05)</a>:</h4>
<p>Ooh nice! I'm gonna pull the branch locally and see how those changes affect tests</p>



<a name="213040348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213040348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213040348">(Oct 12 2020 at 13:48)</a>:</h4>
<p>Hey y'all I'm so sorry, something last minute came up on Friday, I've been meaning to come on and apologize. I do expect to be around later today and will review and leave comments.</p>



<a name="213082110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213082110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213082110">(Oct 12 2020 at 20:21)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> btw I'm finishing up a few tasks from lang-team meeting but I plan to do some chalk stuff at ~4:30</p>



<a name="213082182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213082182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213082182">(Oct 12 2020 at 20:22)</a>:</h4>
<p>Awesome. I'm looking over the variance PR.</p>



<a name="213089882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213089882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213089882">(Oct 12 2020 at 21:51)</a>:</h4>
<p>Okay, so I pulled this branch</p>



<a name="213089885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213089885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213089885">(Oct 12 2020 at 21:51)</a>:</h4>
<p>There are a few tests failing:</p>



<a name="213089889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213089889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213089889">(Oct 12 2020 at 21:51)</a>:</h4>
<div class="codehilite"><pre><span></span><code>    test::existential_types::dyn_associated_type_binding
    test::existential_types::dyn_binders_reverse
    test::unify::forall_equality
    test::unify::forall_equality_solveable_simple
    test::unify::forall_equality_unsolveable_simple
</code></pre></div>



<a name="213089972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213089972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213089972">(Oct 12 2020 at 21:52)</a>:</h4>
<p><code>dyn_binders_reverse</code> actually <em>fixes</em> the test, since it's broken for SLG because of <a href="https://github.com/rust-lang-nursery/chalk/issues/234">chalk#234</a></p>



<a name="213090006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213090006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213090006">(Oct 12 2020 at 21:53)</a>:</h4>
<p>But all the others look related to <code>forall</code></p>



<a name="213090457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213090457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213090457">(Oct 12 2020 at 22:00)</a>:</h4>
<p>But...these constraints might be...correct?</p>



<a name="213252121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252121">(Oct 14 2020 at 06:57)</a>:</h4>
<p>Okay so I did some more work on this.</p>



<a name="213252130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252130">(Oct 14 2020 at 06:57)</a>:</h4>
<p>I've gotten all the tests to pass</p>



<a name="213252218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252218">(Oct 14 2020 at 06:58)</a>:</h4>
<p>But...the output for <code>dyn_binders_reverse</code> test (the universes) changed</p>



<a name="213252266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252266">(Oct 14 2020 at 06:59)</a>:</h4>
<p>This is because we relate two <code>dyn</code> types, create new universes, don't reference them, but then relate others later</p>



<a name="213252290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252290">(Oct 14 2020 at 06:59)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Think you could take a look at the branch?</p>



<a name="213252323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252323">(Oct 14 2020 at 06:59)</a>:</h4>
<p>But, this got me thinking a bit. The way we handle universes doesn't seem...quite right.</p>



<a name="213252420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252420">(Oct 14 2020 at 07:01)</a>:</h4>
<p>Take this example:</p>
<div class="codehilite"><pre><span></span><code>program {
            trait Eq&lt;T&gt; { }
            impl&lt;T&gt; Eq&lt;T&gt; for T { }

            struct Unit { }
            struct Ref&lt;&#39;a, T&gt; { }
}
goal { for&lt;&#39;a, &#39;b&gt; fn(Ref&lt;&#39;a, Ref&lt;&#39;b, Ref&lt;&#39;a, Unit&gt;&gt;&gt;): Eq&lt;for&lt;&#39;c, &#39;d&gt; fn(Ref&lt;&#39;c, Ref&lt;&#39;d, Ref&lt;&#39;d, Unit&gt;&gt;&gt;)&gt; }
</code></pre></div>



<a name="213252515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252515">(Oct 14 2020 at 07:02)</a>:</h4>
<p>The solution we get back has the constraints <code>'!1_0: '!1_1</code>, <code>'!1_1: '!1_0</code>, <code>'!2_0: '!2_1</code>, and <code>'!2_1: '!2_0</code></p>



<a name="213252529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252529">(Oct 14 2020 at 07:02)</a>:</h4>
<p>Basically that <code>'a ='b</code> and <code>'c = 'd</code></p>



<a name="213252535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252535">(Oct 14 2020 at 07:02)</a>:</h4>
<p>Which makes sense</p>



<a name="213252540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252540">(Oct 14 2020 at 07:02)</a>:</h4>
<p><em>but</em></p>



<a name="213252581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252581">(Oct 14 2020 at 07:03)</a>:</h4>
<p>The way these universes are numbered and by the rules we've established, universe 2 can see/name universe 1</p>



<a name="213252590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252590">(Oct 14 2020 at 07:03)</a>:</h4>
<p>But they're under separate binders!</p>



<a name="213252675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213252675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213252675">(Oct 14 2020 at 07:04)</a>:</h4>
<p>This confuses me and I don't know enough here to know if this is actually what we want (in a perfect world)</p>



<a name="213808535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808535">(Oct 19 2020 at 16:08)</a>:</h4>
<p>Hmm</p>



<a name="213808539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808539">(Oct 19 2020 at 16:08)</a>:</h4>
<p>So</p>



<a name="213808577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808577">(Oct 19 2020 at 16:08)</a>:</h4>
<p>Oh, I think I see what you're confused about</p>



<a name="213808581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808581">(Oct 19 2020 at 16:08)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> it's a bit more subtle than that</p>



<a name="213808587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808587">(Oct 19 2020 at 16:08)</a>:</h4>
<p>it's true that U2 can "see" U1</p>



<a name="213808594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808594">(Oct 19 2020 at 16:08)</a>:</h4>
<p>however</p>



<a name="213808634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808634">(Oct 19 2020 at 16:09)</a>:</h4>
<p>they will never actually directly come into contact</p>



<a name="213808839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808839">(Oct 19 2020 at 16:10)</a>:</h4>
<p>I wrote something about this</p>



<a name="213808960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213808960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213808960">(Oct 19 2020 at 16:11)</a>:</h4>
<p>check out <a href="https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/placeholders_and_universes.html#what-is-a-universe">this section of the rustc-dev-guide</a></p>



<a name="213809037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809037">(Oct 19 2020 at 16:12)</a>:</h4>
<p>Oh, I'll check it out</p>



<a name="213809085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809085">(Oct 19 2020 at 16:12)</a>:</h4>
<p>in particular <strong>Representing universes with just a counter</strong></p>



<a name="213809123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809123">(Oct 19 2020 at 16:13)</a>:</h4>
<p>basically this is an optimization that lets us avoid using a full tree and instead use just a counter</p>



<a name="213809328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809328">(Oct 19 2020 at 16:14)</a>:</h4>
<p>Cool okay</p>



<a name="213809336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809336">(Oct 19 2020 at 16:14)</a>:</h4>
<p>So, I guess two questions then:</p>



<a name="213809354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809354">(Oct 19 2020 at 16:14)</a>:</h4>
<p>They're somewhat related</p>



<a name="213809435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809435">(Oct 19 2020 at 16:15)</a>:</h4>
<p>1) Does it actually matter the number that we assign to the variables? In my example above, in the test, does it matter that the output changes?</p>



<a name="213809477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809477">(Oct 19 2020 at 16:15)</a>:</h4>
<p>not really</p>



<a name="213809541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809541">(Oct 19 2020 at 16:16)</a>:</h4>
<p>2) When we give back constraints to the caller after solving, how does the caller know which variables are which</p>



<a name="213809608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809608">(Oct 19 2020 at 16:16)</a>:</h4>
<p>maybe the question is, how/why does it care</p>



<a name="213809618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809618">(Oct 19 2020 at 16:16)</a>:</h4>
<p>however, there is another question</p>



<a name="213809633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809633">(Oct 19 2020 at 16:17)</a>:</h4>
<p>which is how "eagerly" we should be solving these constraints</p>



<a name="213809667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809667">(Oct 19 2020 at 16:17)</a>:</h4>
<p>I've been leaning towards a shift that makes it more eager -- that is, that makes chalk try to resolve higher-ranked constraints like these and not give them back to rustc</p>



<a name="213809685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809685">(Oct 19 2020 at 16:17)</a>:</h4>
<p>but let's leave that aside for a second</p>



<a name="213809712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809712">(Oct 19 2020 at 16:17)</a>:</h4>
<p>That might be useful</p>



<a name="213809717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809717">(Oct 19 2020 at 16:17)</a>:</h4>
<p>if the variables are part of universes that do not exist in the query</p>



<a name="213809835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809835">(Oct 19 2020 at 16:18)</a>:</h4>
<p>then the idea is that the query response, when instantiated in the caller's environment, will create fresh universes and fresh variables</p>



<a name="213809842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809842">(Oct 19 2020 at 16:18)</a>:</h4>
<p>but it's true the caller doesn't know which lexical names they corresponded to</p>



<a name="213809867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213809867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213809867">(Oct 19 2020 at 16:18)</a>:</h4>
<p>it only knows that there was "some variable" in universe X etc</p>



<a name="213810036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213810036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213810036">(Oct 19 2020 at 16:20)</a>:</h4>
<p>Hmm</p>



<a name="213810275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213810275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213810275">(Oct 19 2020 at 16:21)</a>:</h4>
<p>Okay, well, I think the variance PR is ready for another look, if you have time <span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>



<a name="213814249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/213814249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#213814249">(Oct 19 2020 at 16:52)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> ok!</p>



<a name="214447706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214447706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214447706">(Oct 24 2020 at 20:26)</a>:</h4>
<p>Thanks so much for working on this! Recursing into tys to only generalize the lifetimes seems like a good change to make, much more efficient.</p>
<p>We've been working on more tests for this, and I had a question regarding what we expect to happen with the generalizer, and inference var lifetimes. Specifically, I have a test like this:</p>
<div class="codehilite"><pre><span></span><code>forall&lt;&#39;a, &#39;b&gt; {
    exists&lt;U&gt; {
        Subtype(&amp;&#39;a u32, U),
        Subtype(&amp;&#39;b u32, U)
    }
}
</code></pre></div>


<p>From my understanding of how the generalizer is supposed to work, I expect this to output something like:</p>
<div class="codehilite"><pre><span></span><code>Unique; for&lt;?U1&gt; { substitution [?0 := &amp;&#39;?1 Uint(U32)], lifetime constraints [
    InEnvironment { environment: Env([]), goal: &#39;?1: &#39;!1_0},
    InEnvironment { environment: Env([]), goal: &#39;?1: &#39;!1_1}
] }
</code></pre></div>


<p>However, instead, it just outputs a single lifetime constraint relating <code>'!1_1: '!1_0</code>. This led me to think the generalizer _wasn't_ working, but turns out the variables are generalized, it's just that <code>unify_lifetime_var</code> unconditionally removes the generalized inference var, setting it to the lifetime it is related to. I tried changing that, but then the engine just goes in circles,  and errors with NoPossibleSolution rather than outputting a constraint involving the new inference var. Specifically, it reaches this point, which I would consider a success:</p>
<div class="codehilite"><pre><span></span><code>  0ms DEBUG starting next strand = Strand {
      ex_clause: ExClause {
          subst: [?0 := (&amp;&#39;?0 Uint(U32))],
          ambiguous: false,
          constraints: [],
          subgoals: [
              Positive(
                  InEnvironment {
                      environment: Env([]),
                      goal: &#39;?0: &#39;!1_1,
                  },
              ),
              Positive(
                  InEnvironment {
                      environment: Env([]),
                      goal: &#39;?0: &#39;!1_0,
                  },
              ),
          ],
          delayed_subgoals: [],
          answer_time: TimeStamp {
              clock: 0,
          },
          floundered_subgoals: [],
      },
      selected_subgoal: None,
  }
</code></pre></div>


<p>but instead of returning it, it tries to solve the lifetime constraints, and fails. Any ideas for where my reasoning is wrong here, or if it's correct, how I can get the engine to actually output those subgoals rather than try to solve them itself and fail?</p>



<a name="214448853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214448853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214448853">(Oct 24 2020 at 20:51)</a>:</h4>
<p>Hold on, reading this</p>



<a name="214448922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214448922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214448922">(Oct 24 2020 at 20:53)</a>:</h4>
<p><code>?0 := (&amp;'?0 Uint(U32))</code> so that's obviously wrong</p>



<a name="214450090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214450090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214450090">(Oct 24 2020 at 21:19)</a>:</h4>
<blockquote>
<p>unify_lifetime_var unconditionally removes the generalized inference var, setting it to the lifetime it is related to</p>
</blockquote>



<a name="214450095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214450095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214450095">(Oct 24 2020 at 21:19)</a>:</h4>
<p>You mean, it ignores variance?</p>



<a name="214459278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214459278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214459278">(Oct 25 2020 at 00:54)</a>:</h4>
<p>So, pushed some changes that should fix that!</p>



<a name="214467190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214467190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214467190">(Oct 25 2020 at 04:12)</a>:</h4>
<blockquote>
<p>So, pushed some changes that should fix that!</p>
</blockquote>
<p>Awesome!</p>
<p>Looks like one of the tests had an extra comma, so I pushed a fix for that. But otherwise this looks good. I think the difference which caused our secondary error was just removing the <code>unify_var_value</code> branch in <code>unify_lifetime_var</code> entirely, rather than gating it behind <code>variance == Variance::Invariant</code>.</p>
<p>Besides more tests, is there anything else you know of that this PR needs to be mergeable?</p>



<a name="214467876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214467876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214467876">(Oct 25 2020 at 04:30)</a>:</h4>
<p>Not entirely sure. <span class="user-mention" data-user-id="116009">@nikomatsakis</span> is going to review when he has time</p>



<a name="214576865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214576865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214576865">(Oct 26 2020 at 14:03)</a>:</h4>
<p>I will put some time into this today I thnk</p>



<a name="214579815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214579815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214579815">(Oct 26 2020 at 14:25)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> awesome. I'm around to discuss if you need</p>



<a name="214635625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214635625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214635625">(Oct 26 2020 at 21:29)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I'm guessing you didn't get to this today?</p>



<a name="214635654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214635654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214635654">(Oct 26 2020 at 21:29)</a>:</h4>
<p>Heh, I just finished up the lang-team work I was doing and was going to put in a bit of time here now</p>



<a name="214635668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214635668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214635668">(Oct 26 2020 at 21:29)</a>:</h4>
<p>I've not been doing a great job holding out the time slots I defined for chalk :(</p>



<a name="214635671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214635671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214635671">(Oct 26 2020 at 21:29)</a>:</h4>
<p>but it's a useful tension</p>



<a name="214635697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214635697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214635697">(Oct 26 2020 at 21:30)</a>:</h4>
<p>anyway, let me read a bit back</p>



<a name="214636225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214636225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214636225">(Oct 26 2020 at 21:34)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> this is <a href="https://github.com/rust-lang/chalk/pull/609">https://github.com/rust-lang/chalk/pull/609</a>, right ?</p>



<a name="214636238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214636238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214636238">(Oct 26 2020 at 21:34)</a>:</h4>
<p>just to make sure I'm not reading deeply into the wrong thing :P</p>



<a name="214636247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214636247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214636247">(Oct 26 2020 at 21:34)</a>:</h4>
<p>yes</p>



<a name="214638950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214638950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214638950">(Oct 26 2020 at 22:02)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> one thing I notice as I read</p>



<a name="214638965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214638965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214638965">(Oct 26 2020 at 22:02)</a>:</h4>
<p>in the Rust code, if the variance is <code>Invariant</code>, the generalizer doesn't always generalize :)</p>



<a name="214638984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214638984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214638984">(Oct 26 2020 at 22:02)</a>:</h4>
<p>although hmm I think I remember that this was potentially a bug in some cases</p>



<a name="214639249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214639249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214639249">(Oct 26 2020 at 22:05)</a>:</h4>
<p>well, we certainly do it though</p>



<a name="214639706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214639706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214639706">(Oct 26 2020 at 22:10)</a>:</h4>
<p>e.g., <a href="https://github.com/rust-lang/rust/blob/0da6d42f297642a60f2640ec313b879b376b9ad8/compiler/rustc_infer/src/infer/combine.rs#L615-L633">here</a></p>



<a name="214640466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214640466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214640466">(Oct 26 2020 at 22:19)</a>:</h4>
<p>Yes</p>



<a name="214640474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214640474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214640474">(Oct 26 2020 at 22:19)</a>:</h4>
<p>I remember seeing that</p>



<a name="214640485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214640485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214640485">(Oct 26 2020 at 22:19)</a>:</h4>
<p>And I'm trying to remember what I did</p>



<a name="214640546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214640546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214640546">(Oct 26 2020 at 22:20)</a>:</h4>
<p>I think I ignored that because we aren't tracking variance when generalizing</p>



<a name="214640997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214640997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214640997">(Oct 26 2020 at 22:26)</a>:</h4>
<p>I'm a bit surprised by the numbers we assign</p>



<a name="214641016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641016">(Oct 26 2020 at 22:26)</a>:</h4>
<p>I'd have expected <code>for&lt;'a, 'b&gt;</code> to call <code>'a</code> <code>'!1_0</code> and <code>'b = '!1_1</code></p>



<a name="214641061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641061">(Oct 26 2020 at 22:27)</a>:</h4>
<p>ah, wait, maybe it does</p>



<a name="214641087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641087">(Oct 26 2020 at 22:27)</a>:</h4>
<p>and maybe the code in <code>push_lifetime_eq_goals</code> is just not right</p>



<a name="214641092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641092">(Oct 26 2020 at 22:27)</a>:</h4>
<p>(also the name of that function is not right)</p>



<a name="214641127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641127">(Oct 26 2020 at 22:27)</a>:</h4>
<p>heh you might hate me for this</p>



<a name="214641166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641166">(Oct 26 2020 at 22:28)</a>:</h4>
<p>there are a few definitions of variance that we use in Rust</p>



<a name="214641181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641181">(Oct 26 2020 at 22:28)</a>:</h4>
<p>well, just 1, but polonius has a "mildly different take"</p>



<a name="214641205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641205">(Oct 26 2020 at 22:28)</a>:</h4>
<p>anyway point is that if you say that <code>&amp;'a u32 &lt;: &amp;'b u32</code>, you want <code>'a: 'b</code> as the condition</p>



<a name="214641230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641230">(Oct 26 2020 at 22:28)</a>:</h4>
<p>in rust we call this <em>contravariance</em> because <code>'a: 'b</code> means <code>'a &gt;= 'b</code> in terms of lifetime</p>



<a name="214641244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641244">(Oct 26 2020 at 22:28)</a>:</h4>
<p>(but <code>&lt;:</code> is like <code>&lt;=</code> in terms of "sets of values")</p>



<a name="214641262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641262">(Oct 26 2020 at 22:29)</a>:</h4>
<p>point is, this code:</p>



<a name="214641275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641275">(Oct 26 2020 at 22:29)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="n">matches</span><span class="o">!</span><span class="p">(</span><span class="n">variance</span><span class="p">,</span><span class="w"> </span><span class="n">Variance</span>::<span class="n">Invariant</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">Variance</span>::<span class="n">Contravariant</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="bp">self</span><span class="p">.</span><span class="n">goals</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">InEnvironment</span>::<span class="n">new</span><span class="p">(</span><span class="w"></span>
<span class="w">                </span><span class="bp">self</span><span class="p">.</span><span class="n">environment</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">WhereClause</span>::<span class="n">LifetimeOutlives</span><span class="p">(</span><span class="n">LifetimeOutlives</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">a</span>: <span class="nc">b</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="nc">a</span><span class="w"> </span><span class="p">}).</span><span class="n">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">interner</span><span class="p">),</span><span class="w"></span>
<span class="w">            </span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>probably wants to be <code>LifetimeOutlives { a, b }</code></p>



<a name="214641585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214641585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214641585">(Oct 26 2020 at 22:32)</a>:</h4>
<p>oh, hmm, it seems like <span class="user-mention" data-user-id="116118">@Matthew Jasper</span> has made the same comment :) also pointed out that the name <code>push_lifetime_eq_goal</code> is not accurate anymore</p>



<a name="214642037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/214642037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#214642037">(Oct 26 2020 at 22:39)</a>:</h4>
<p>Yep haha</p>



<a name="215204299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204299">(Oct 31 2020 at 18:15)</a>:</h4>
<p>Possibly-quick question: do we really want to be generalizing consts?</p>
<p>I've been trying to come up with a test case for this, but I can't really think of one. Is there ever a situation where const generics have subtype relationships and we might want to output "const constraints" similar to lifetime constraints, or where generalizing a const is useful from rustc's perspective?</p>



<a name="215204315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204315">(Oct 31 2020 at 18:15)</a>:</h4>
<p>const generics do not have subtype relations (yet)</p>



<a name="215204368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204368">(Oct 31 2020 at 18:16)</a>:</h4>
<p>don't know enough about the rest of your question though. What's the job of the generalizer?</p>



<a name="215204701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204701">(Oct 31 2020 at 18:23)</a>:</h4>
<p>Ah - the generalizer ensures that we avoid forcing equality on things which should be allowed to be subtypes</p>
<p>So if we check something like Subtype(Foo&lt;3&gt;, U) in a covariant context, without the generalizer we just set U to Foo&lt;3&gt;. But with the generalizer, we set U to Foo&lt;T&gt;, and introduce a T: 3 constraint</p>



<a name="215204769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204769">(Oct 31 2020 at 18:24)</a>:</h4>
<p>yeah, you can mostly force equality then</p>



<a name="215204839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204839">(Oct 31 2020 at 18:25)</a>:</h4>
<p>afaik chalk doesn't yet deal with unevaluated constants, so that shouldn't matter yet</p>



<a name="215204930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204930">(Oct 31 2020 at 18:27)</a>:</h4>
<p>yeah - that's fair!</p>
<p>If it _is_ something we want in the future though, I think we could just leave the generalizer in? Only harm it's doing right now is introducing a few more variables which are immediately resolved</p>



<a name="215204940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215204940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Ross <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215204940">(Oct 31 2020 at 18:27)</a>:</h4>
<p>Generalizer for consts, I mean. We need it in general since generalizing lifetimes is required</p>



<a name="215205021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215205021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215205021">(Oct 31 2020 at 18:28)</a>:</h4>
<p>hmm, i think it's fine. But it will be a long time until even rustc will allow const subtyping, if ever</p>



<a name="215205117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/215205117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#215205117">(Oct 31 2020 at 18:31)</a>:</h4>
<p>even unevaluated constants don't need subtyping, but do lazily emit <code>ConstEquate(a, b)</code> predicates to prevent some potential cycles in rustc - so you can't just equate them</p>



<a name="216155865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/216155865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#216155865">(Nov 09 2020 at 23:24)</a>:</h4>
<p>So <span class="user-mention" data-user-id="116118">@Matthew Jasper</span> -- are you happy with <a href="https://github.com/rust-lang/chalk/pull/609">https://github.com/rust-lang/chalk/pull/609</a> ? I didn't re-read it in depth but I think the major things I saw the first time were fixed</p>



<a name="216156025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/216156025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#216156025">(Nov 09 2020 at 23:26)</a>:</h4>
<p>it'll need a rebase for erased and empty lifetimes, but that should be pretty easy</p>



<a name="216179691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/216179691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#216179691">(Nov 10 2020 at 07:48)</a>:</h4>
<p>I'm happy with it.</p>



<a name="216273667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/216273667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#216273667">(Nov 10 2020 at 21:00)</a>:</h4>
<p>ok r=me then</p>



<a name="216273742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20Generalizer%20work/near/216273742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20Generalizer.20work.html#216273742">(Nov 10 2020 at 21:01)</a>:</h4>
<p>I'll try to rebase later tonight</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>